package com.luoxue.execsql.common.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TableData<T extends BaseEntity> {
    private List<T> list;
    private Long total;

    public static <T extends BaseEntity> ResultBody genResult(IPage<T> page) {
        return ResultBody.ok("查询成功", new TableData<>(page.getRecords(), page.getTotal()));
    }
}
